<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>计算属性getter 和setter </title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
        {{fullName}}
    </div>
    <script>
         var vm = new Vue({
             el: "#app",
             data: {
                 firstName: "Dell",
                 lastName: "Lee",
             },
         //    计算属性 存在一个缓存机制
             computed: {
                 fullName: {
                     // 数据变化则自动执行get方法 默认只有getter
                     get: function () {
                         console.log("bbbb")
                         return this.firstName + " " + this.lastName
                     },
                     // 当fullName 发生变化的时候，将执行set方法
                     set: function (value) {
                        console.log(value);
                        var arr = value.split(" ");
                        this.firstName = arr[0];
                        this.lastName = arr[1];
                         console.log(arr);


                     }
                 }
             }
         });
    </script>
</body>
</html>